<?php
namespace app\model;

use think\Db;
use think\Model;
class Column extends Model
{
    protected $autoWriteTimestamp = true;
    public static function findColumn($id){
        $info = Column::where('id',$id)
            ->field('id,site_id,pid,title,english,sort,keyword,description,seo_title,seo_keyword,seo_description,url,img,bckimg,indexImg,drop,show,content,additional1,additional2,create_time')
            ->find();
        return $info;
    }
    public static function saveColumn($data)
    {

    }
    public static function delColumn($id)
    {
        Db::startTrans();
        try {
            Db::name('column')->where('id','in',$id)->delete();
            Db::name('article')->where('column_id','in',$id)->update(['delete_time'=>time(),'is_delete'=>1]);
            $res = ['code'=>200,'msg'=>'删除成功'];
            Db::commit();
        }catch (\Exception $e){
            $res = ['code'=>202,'msg'=>'删除失败,原因:'.$e->getMessage()];
        }
        return $res;
    }
}